﻿using Ec_System.API;
using Ec_System.MvcAPI.Extensions;
using Ec_System.MvcService.BLL;
using Ec_System.MvcService.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Xml;

namespace Ec_System.MvcAPI.Controllers
{
    public class QrCodeController : ApiController
    {
        [HttpGet]
        public HttpResponseMessage GetQrInfoByCode(string qrCode)
        {
            string ip = GetIP.GetClientIP();//?
            var model = QrCodeManager.GetQrInfoByCode(qrCode, ip);
            XmlDocument xml = new XmlDocument();
            xml.LoadXml(SerializeHelper.Serialize<QrCodeData>(model));
            return new HttpResponseMessage
            {
                RequestMessage = Request,
                Content = new XmlContent(xml)
            };
        }
    }
}
